import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, Integer, SMALLINT, DECIMAL, Enum, TEXT, TIMESTAMP

Base = declarative_base()
# 创建新表
def new_table():
  Base = declarative_base()
  engine = create_engine('mysql+pymysql://root:123456@localhost:3306/mydb')
  Base.metadata.create_all(engine)
  
  
class TCL(Base):
    __tablename__ = "TCL_Result"

    study_id = Column(String(64), primary_key=True)
    inv_pred = Column(String(64))
    inv_pred_pro = Column(String(64))
    men_pred = Column(String(64))
    men_pred_pro = Column(String(64))
    
    def __init__(self, study_id, inv_pred,inv_pred_pro,men_pred, men_pred_pro):
        self.study_id = study_id
        self.inv_pred = inv_pred
        self.inv_pred_pro = inv_pred_pro
        self.men_pred = men_pred
        self. men_pred_pro =  men_pred_pro

class Patient(db.Model):
    __tablename__ = 'patient'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255, 'utf8_general_ci'), info='姓名')
    sex = db.Column(db.String(4, 'utf8_general_ci'), info='性别')
    pid = db.Column(db.Integer, index=True, info='患者编号') 
    borntime = db.Column(db.DateTime, info='出生日期')
    hospital = db.Column(db.String(255), info='医院名')

    def __init__(self,name,sex,pid,hospital,borntime):
        self.sex = sex
        self.pid = pid
        self.name = name
        self.hospital = hospital
        self.borntime = borntime